<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:replace="common/template :: res(title='用户列表')">

</head>
<body>
	<script type="text/javascript">
		$(function() {
			$('#ctable').bootstrapTable({
				url : 'q/users',
				method : 'get',
				striped : true,
				search : "true",
				showColumns : "true",
				showFooter : "true",

				columns : [ {
					field : 'merDate',
					title : '开户日期'
				}, {
					field : 'userType',
					title : '用户类型',
					formatter:function(value){
						return value==1?"个人":"企业"
					}
				}, {
					field : 'mobileNo',
					title : '手机号'
				}, {
					field : 'realName',
					title : '真实姓名'
				}, {
					field : 'enterName',
					title : '企业名称'
				} , {
					field : 'amount',
					title : '可用金额'
				}, {
					field : 'repaymentBal',
					title : '还款金额'
				}, {
					field : 'freezeBal',
					title : '冻结金额'
				}, {
					field : 'ipsAuthNo',
					title : '授权号'
				},{
		        	 field: 'oper',
			         title:'操作',
			         formatter:function(value,row,index){
			        	 var showInfo = row.userType==1?"自动投标签约":"自动还款签约";
			        	 var html= '<button type="button" class="btn btn-default" data-ips="'+row.ipsAcctNo+'" role="queryuser">实时查询</button> &nbsp;';
			        	 html +='<button type="button" class="btn btn-default" data-username="'+row.userName+'" role="loginIps">登录IPS</button> &nbsp;';
			        	 html +='<button type="button" class="btn btn-default" data-iano="'+row.ipsAcctNo+'" data-usertype="'+row.userType+'" role="autoLogin">'+showInfo+'</button> &nbsp;';
			        	 html +='<button type="button" class="btn btn-default" data-iano="'+row.ipsAcctNo+'" data-usertype="'+row.userType+'" role="redpack">发放5元红包</button> &nbsp;';
			        	 return html;
			         }
		        }]

			});
			//support IE
			$('#ctable').on('post-body.bs.table',function(){
				$('button[role=queryuser]').click(function() {
					var ips=this.dataset.ips;
					doRequest({
						url:'q/ipsbalance',
						data:{
							ipsAcctNo:ips
						}
					},function(d){
						var html ='账户余额:'+d.balance.curBal+' 可用余额:'+d.balance.availBal+'  冻结余额:'+d.balance.freezeBal+'<br /> ';
						html +='风险准备金余额:'+d.balance.marginBal+'   还款专用余额:'+d.balance.repaymentBal+'';
						
						print(html,20000);
					});
				});
				
				$('button[role=loginIps]').click(function() {
					var userName=this.dataset.username;
					$('#userName').val(userName);
					$('#submitForm').submit();
				});
				$('button[role=autoLogin]').click(function() {
					var iano=this.dataset.iano;
					var usertype=this.dataset.usertype;
					
					doRequest({
						url:'autoLogin',
						type:'POST',
						data:{
							userType:usertype,
							ipsAcctNo:iano,
							signedType:usertype==1?0:1
						}
					},function(data){
						console.log(data);
						$('#merchantID').val(data.merchantID);
						$('#sign').val(data.sign);
						$('#request').val(data.requestBody);
						$('#submitForm2').submit();
					});
					
				});
				$('button[role=redpack]').click(function() {
					var iano=this.dataset.iano;
					var usertype=this.dataset.usertype;
					
					doRequest({
						url:'redPack',
						type:'POST',
						data:{
							usrType:usertype,
							userIpsAccount:iano,
							amount:5
						}
					},function(data){
						print('发放成功');
					});
					
				});
				
				
				
			});

		});
	</script>
	<div class="alert alert-success toptips" role="alert" id="js_tooltips"  style="display:none;z-index:100;">信息展示窗口</div>
	<div class="page-header">
		<h2>
			江苏亦融在线 <small>支付调试</small>
		</h2>

	</div>
	<ol class="breadcrumb">
		<li><a href="index">首页</a></li>
		<li class="active">用户列表</li>
	</ol>

	<table id="ctable">
	</table>

<div style="display: none;">
		<form action="http://180.168.26.114:20010/p2p-deposit/login.html" method="post" id="submitForm" target="_blank">
		
			<input type="text" name="userName" id="userName" />
			<input type="text" name="merchantId" value="1184980025" />
		</form>
	</div>
	
	<div style="display: none;">
		<form action="http://180.168.26.114:20010/p2p-deposit/gateway.htm" method="post" id="submitForm2" target="_blank">
		
			<input type="text" name="operationType" id="operationType" value="user.autoSign"/>
			<input type="text" name="merchantID" id="merchantID"/>
			<input type="text" name="sign" id="sign"/>
			<input type="text" name="request" id="request"/>
		</form>
	</div>
</body>
</html>